<template>
	<view class="container">
		<navSearchBar inputWidth="400" :focus="true" :placeholder="placeholder"
			@confirmSearch="confirmSearch"></navSearchBar>
		<view class="empty" v-if="!productData.length">
			<img src="@/static/wx.png" alt="" />
		</view>
		<view class="product" v-else>
			<view class="product-item" v-for="item in productData" :key="item.id" @click="toDetail">
				<img :src="item.src" alt="" />
				<text>{{item.text}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				placeholder: "搜索您心仪的产品",
				productData: [{
						id: 1,
						src: "../../static/avatar_boy.png",
						text: "青岛世界艺博园"
					},
					{
						id: 1,
						src: "../../static/avatar_boy.png",
						text: "青岛世界艺博园"
					},
					{
						id: 1,
						src: "../../static/avatar_boy.png",
						text: "青岛世界艺博园"
					},
					{
						id: 1,
						src: "../../static/avatar_boy.png",
						text: "青岛世界艺博园"
					},
					{
						id: 1,
						src: "../../static/avatar_boy.png",
						text: "青岛世界艺博园"
					},
				]
			};
		},
		methods: {
			confirmSearch() {},
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		height: 100vh;
		display: flex;
		flex-direction: column;

	}

	.empty {
		flex-grow: 1;
		border: 1px solid red;

		image {
			width: 100%;
			height: 100%;
		}

	}

	.product {
		display: grid;
		grid-template-columns: 1fr 1fr;
		grid-gap: 30rpx;
		padding: 30rpx;

		.product-item {
			width: 330rpx;
			height: 314rpx;
			border: 2px solid red;
			border-radius: 20rpx;
		}

		img {
			width: 100%;
			height: 246rpx;
		}

		text {
			display: block;
			line-height: 68rpx;
			text-align: center;
			font-size: 28rpx;
		}
	}
</style>